package com.javacodegeeks.youtube.test;

import java.util.List;

import com.javacodegeeks.youtube.YouTubeManager;
import com.javacodegeeks.youtube.model.YouTubeVideo;

public class YouTubeTester {
	
	public static void main(String[] args) throws Exception {
		
		String clientID = "JavaCodeGeeks";
				
		String textQuery = "exaltado";
		
		int maxResults = 4;
		boolean filter = true;
		int timeout = 2000;
		
		YouTubeManager ym = new YouTubeManager(clientID);
		
		List<YouTubeVideo> videos = ym.retrieveVideos(textQuery, maxResults, filter, timeout);
		
		for (YouTubeVideo youtubeVideo : videos) {
			System.out.println(youtubeVideo.getTitle());
			System.out.println(youtubeVideo.getDescription());
			System.out.println(youtubeVideo.getUser());
			System.out.println(youtubeVideo.getVideoId());
			System.out.println(youtubeVideo.getWebPlayerUrl());
			System.out.println("Thumbnails");
			
			for (String thumbnail : youtubeVideo.getThumbnails()) {
				System.out.println("\t" + thumbnail);
			}
			
			System.out.println(youtubeVideo.getEmbeddedWebPlayerUrl());

			//Alteracao
			String linkYoutube = youtubeVideo.getEmbeddedWebPlayerUrl();
			
			String[] addMusica = linkYoutube.split("&");
			
			System.out.println("");
			System.out.println(addMusica[0]);
			//System.out.println("Link solicitado: "+(addMusica[0]));
			System.out.println("");
			System.out.println("****************************************************************");
			System.out.println("");
		}
		
	}

}
